using System;
using System.Collections.Generic;
using System.Data;
using BikeSystem.Models;
using BikeSystem.DAL;
namespace BikeSystem.BLL
{
    public class BikeManager
    {
        BikeService bikeService = new BikeService();
        public Bike GetBikeByBikeNo(String BikeNo)
        {
            return bikeService.GetBikeByBikeNo(BikeNo);
        }

        public IList<Bike> GetAllBikes()
        {
            return bikeService.GetAllBike();
        }

        public string InsertBike(Bike bike)
        {
           // Bike bi = new Bike();
            string message = string.Empty;

            Bike exitbike = bikeService.GetBikeByBikeNo(bike.BikeNo);
            if (null != exitbike)
            {
                message = "Existing Bike No.";
            }
            else
            {
                bikeService.InsertBike(bike);
                message = "Added Bike success.";
            }
            return message;
        }

        public string DeleteBike(string BikeNo)
        {
            string message = string.Empty;
            int num = bikeService.DeleteBike(BikeNo);
            if (num > 0)
                message = "Deleted Unsuccess";
            else
                message = "Deleted Success";
            return message;

        }

        public string UpdateBike(Bike bike)
        {
            string message = string.Empty;
            int num = bikeService.UpdateBike(bike);
            if (num == 1)
                message = "Updated Unsuccess.";
            else
                message = "Updated Success";
            return message;
        }


    }
}
